package com.google.blockly.ohos.demo.view;

import com.google.blockly.ohos.demo.EventHelper;
import com.google.blockly.ohos.demo.FlyoutDemos;
import com.google.blockly.ohos.demo.ResourceTable;
import ohos.agp.components.ListContainer;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class FlyoutDemosTest {

    private FlyoutDemos ability;

    @Before
    public void setUp() throws Exception {
        ability = EventHelper.startAbility(FlyoutDemos.class);
    }

    @After
    public void tearDown() throws Exception {
        EventHelper.clearAbilities();
    }

    @Test
    public void clickNoCategoriesToolbox() throws Exception {
        ListContainer listContainer = (ListContainer) ability.findComponentById(ResourceTable.Id_demo_list);
        EventHelper.triggerClickEvent(ability, listContainer.getComponentAt(0));
        Thread.sleep(2000);
        Assert.assertNotNull("It's right", listContainer);
    }
    @Test
    public void clickAlwaysOpenToolbox() throws Exception {
        ListContainer listContainer = (ListContainer) ability.findComponentById(ResourceTable.Id_demo_list);
        EventHelper.triggerClickEvent(ability, listContainer.getComponentAt(1));
        Thread.sleep(2000);
        Assert.assertNotNull("It's right", listContainer);
    }


}